import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "pc" */ '../views/pc/login.vue')
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children: [
      {
        path: '/userList',
        name: 'userList',
        component: () => import(/* webpackChunkName: "pc" */ '../views/pc/userList.vue')
      },
      {
        path: '/productList',
        name: 'productList',
        component: () => import(/* webpackChunkName: "pc" */ '../views/pc/productList.vue')
      },
      {
        path: '/stockList',
        name: 'stockList',
        component: () => import(/* webpackChunkName: "pc" */ '../views/pc/stockList.vue')
      },
      {
        path: '/intoStock',
        name: 'intoStock',
        component: () => import(/* webpackChunkName: "pc" */ '../views/pc/intoStock.vue')
      },
      {
        path: '/saleOut',
        name: 'saleOut',
        component: () => import(/* webpackChunkName: "pc" */ '../views/pc/saleout.vue')
      },
      {
        path: '/warehouse',
        name: 'warehouse',
        component: () => import(/* webpackChunkName: "pc" */ '../views/pc/warehouse.vue')
      },
      {
        path: '/factory',
        name: 'factory',
        component: () => import(/* webpackChunkName: "pc" */ '../views/pc/factory.vue')
      },
      {
        path: '/preparer',
        name: 'preparer',
        component: () => import(/* webpackChunkName: "pc" */ '../views/pc/preparer.vue')
      },
      {
        path: '/saleData',
        name: 'saleData',
        component: () => import(/* webpackChunkName: "pc" */ '../views/pc/saleData.vue')
      },
      {
        path: '/company',
        name: 'company',
        component: () => import(/* webpackChunkName: "pc" */ '../views/pc/company.vue')
      },
      {
        path: '/saleUser',
        name: 'saleUser',
        component: () => import(/* webpackChunkName: "pc" */ '../views/pc/saleUser.vue')
      },
    ]
  }
]




const router = new VueRouter({
  routes,
})

router.beforeEach((to, from, next) => {
  // if (to.path === '/login') return next()
  // const userName = window.sessionStorage.userName
  // if (!userName) return next('/login')
  return next()
})




export default router
